﻿using RabbitMQ.Client;
using System;
using System.Text;

namespace TopicModePublish
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var channel = Common.RabbitMQ.GetChannel();

            //交换机
            channel.ExchangeDeclare("mytopicexchange", ExchangeType.Topic, true, false, default);

            for (int i = 0; i < 100; i++)
            {
                var routingKey = i % 10 == 0 ? "*.com" : "*.cn";
                channel.BasicPublish("mytopicexchange", routingKey, default, Encoding.UTF8.GetBytes($"你好{i}"));
            }

        }
    }
}
